# Build recipe for perl-yaml-tiny.
#
# Copyright (c) 2018 Markus Tornow, <tornow@riseup.net>.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

program=YAML-Tiny
version=1.73
release=1

# Set 'outdir' for a nice and well-organized output directory
outdir="${outdir}/${arch}/modules/perl"

tarname=${program}-${version}.tar.gz

# Remote source(s)
fetch=http://cpan.metacpan.org/authors/id/E/ET/ETHER/"$tarname"

description="
YAML::Tiny - Read/Write YAML files with as little code as possible.

YAML::Tiny is a perl class for reading and writing YAML-style files,
written with as little code as possible, reducing load time and memory
overhead.

Most of the time it is accepted that Perl applications use a lot of
memory and modules. The ::Tiny family of modules is specifically
intended to provide an ultralight and zero-dependency alternative to
many more-thorough standard modules.

This module is primarily for reading human-written files (like simple
config files) and generating very simple human-readable files. Note that
I said human-readable and not geek-readable. The sort of files that your
average manager or secretary should be able to look at and make sense
of.

YAML::Tiny does not generate comments, it won't necessarily preserve the
order of your hashes, and it will normalise if reading in and writing
out again.

It only supports a very basic subset of the full YAML specification.

Usage is targeted at files like Perl's META.yml, for which a small and
easily-embeddable module is extremely attractive.

Features will only be added if they are human readable, and can be
written in a few lines of code. Please don't be offended if your request
is refused. Someone has to draw the line, and for YAML::Tiny that
someone is me.

If you need something with more power move up to YAML (7 megabytes of
memory overhead) or YAML::XS (6 megabytes memory overhead and requires a
C compiler).

To restate, YAML::Tiny does not preserve your comments, whitespace, or
the order of your YAML data. But it should round-trip from Perl
structure to file and back again just fine.
"

homepage=http://metacpan.org/pod/YAML::Tiny
license="Artistic License"

# Source documentation
docs="CONTRIBUTING Changes INSTALL LICENSE MANIFEST README"
docsdir="${docdir}/${program}-${version}"

build()
{
    set -e

    unpack "${tardir}/$tarname"

    cd "$srcdir"

    perl Makefile.PL PREFIX=/usr
    make -j${jobs} V=1
    make -j${jobs} DESTDIR="$destdir" install

    # Compress info documents deleting index file for the package
    if test -d "${destdir}/$infodir"
    then
        rm -f "${destdir}/${infodir}/dir"
        lzip -9 "${destdir}/${infodir}"/*
    fi

    # Compress and link man pages (if needed)
    if test -d "${destdir}/$mandir"
    then
        (
            cd "${destdir}/$mandir"
            find . -type f -exec lzip -9 '{}' +
            find . -type l | while read -r file
            do
                ln -sf "$(readlink -- "$file").lz" "${file}.lz"
                rm -- "$file"
            done
        )
    fi

    # Copy documentation
    mkdir -p "${destdir}${docsdir}"
    cp -p $docs "${destdir}${docsdir}/"
}


